package com.dmagic.cms.common.entity;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.MappedSuperclass;

import org.apache.commons.lang3.builder.ToStringBuilder;

import com.dmagic.cms.common.util.SpringSecurityUtils;

/**
 * common of data create and modify info
 * 
 * @author songlin.li
 */
@MappedSuperclass
public abstract class ModifyInfoEntity implements Serializable {
	/**
	 * Comment for <code>serialVersionUID</code>
	 */
	private static final long serialVersionUID = 1L;

	public static final String ISOBSOLETE_DATE_IS_NULL = "isObsoleteDate is null";

	private String createdBy;

	private Date createdOn;

	private String modifiedBy;

	private Date modifiedOn;

	private Date isObsoleteDate;

	public ModifyInfoEntity() {
		this.modifiedBy = SpringSecurityUtils.getCurrentUserName();
		this.modifiedOn = new Date();
		this.createdBy = SpringSecurityUtils.getCurrentUserName();
		this.createdOn = new Date();
	}

	public String getCreatedBy() {
		return createdBy;
	}

	public void setCreatedBy(String createdBy) {
		this.createdBy = createdBy;
	}

	public Date getCreatedOn() {
		return createdOn;
	}

	public void setCreatedOn(Date createdOn) {
		this.createdOn = createdOn;
	}

	public String getModifiedBy() {
		return modifiedBy;
	}

	public void setModifiedBy(String modifiedBy) {
		this.modifiedBy = modifiedBy;
	}

	public Date getModifiedOn() {
		return modifiedOn;
	}

	public void setModifiedOn(Date modifiedOn) {
		this.modifiedOn = modifiedOn;
	}

	public Date getIsObsoleteDate() {
		return isObsoleteDate;
	}

	public void setIsObsoleteDate(Date isObsoleteDate) {
		this.isObsoleteDate = isObsoleteDate;
	}

	@Override
	public String toString() {
		return ToStringBuilder.reflectionToString(this);
	}
}
